package com.tjetc._4abstarct;

public class _3AbstractExercise {
    public static void main(String[] args) {
        /*
                编写一个Employee类，声明为抽象类，包含如下三个属性：name,id,salary.
                提供必要的构造器和抽象方法：work()
                对于Manager类来说，他既是员工，还具有奖金(bonus)的属性。
                请使用继承的思想，设计CommonEmployee类和Manager类，要求类中提供必要的方法进行属性访问，实现work(),提示"经理/普通员工 名字 工作中….. "
                使用 OOP的继承 + 抽象类

                思路分析：
                1.在一个具体的问题中，要分析出有什么类？
                    Employee类 abstract
                    Manager类
                    CommonEmployee类
                2.类的成员
                    属性，方法，构造器，代码块
                3.类之间的关系
         */

        Employee commonEmployee = new CommonEmployee(1, "zhangsan", 10);
        commonEmployee.work();
        Employee manager = new Manager(1, "lisi", 10, 10);
        manager.work();
    }
}

class CommonEmployee extends Employee {

    public CommonEmployee(int id, String name, double salary) {
        super(id, name, salary);
    }

    public CommonEmployee() {
    }

    @Override
    public void work() {
        System.out.println("普通员工：" + getName() + "工作中...");
    }
}

class Manager extends Employee {
    private double bonus;

    public Manager(int id, String name, double salary, double bonus) {
        super(id, name, salary);
        this.bonus = bonus;
    }

    public Manager() {
    }

    @Override
    public void work() {
        System.out.println("经理：" + getName() + "工作中...");
    }

    public double getBonus() {
        return bonus;
    }

    public void setBonus(double bonus) {
        this.bonus = bonus;
    }
}


abstract class Employee {
    private int id;
    private String name;
    private double salary;


    public abstract void work();

    public Employee(int id, String name, double salary) {
        this.id = id;
        this.name = name;
        this.salary = salary;
    }

    public Employee() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

}
